const { name } = require('./package');
const path = require('path');
const resolve = dir => path.resolve(__dirname, dir);

module.exports = {
  webpack: config => {
    config.output.library = `${name}-[name]`;
    config.output.libraryTarget = 'umd';
    config.output.jsonpFunction = `webpackJsonp_${name}`;
    config.output.globalObject = 'window';
    // config.output.publicPath = process.env.NODE_ENV !== 'development' ? `/micro-apps/${name}/` : '/'
    config.output.resolve = {
      alias: {
        '@': resolve('src')// 这样配置后 @ 可以指向 src 目录
      }
    }

    return config;
  },

  devServer: _ => {
    const config = _;

    config.headers = {
      'Access-Control-Allow-Origin': '*',
    };
    config.historyApiFallback = true;

    config.hot = false;
    config.watchContentBase = false;
    config.liveReload = false;

    return config;
  },
};
